﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Web;
using Interfaces;
namespace Components
{
    [Export(typeof(IWebContext))]
    class WebContext : IWebContext
    {
        public void clearSession()
        {
            HttpContext.Current.Session.Clear();
        }

        public bool containsInSession(string key)
        {
            return HttpContext.Current.Session[key] != null;
        }

        public void removeFromSession(string key)
        {
            HttpContext.Current.Session.Remove(key);
        }

        public  string getQueryStringValue(string key)
        {
            return HttpContext.Current.Request.QueryString.Get(key);
        }

        private void SetInSession(string key, object value)
        {
            if (HttpContext.Current == null ||
            HttpContext.Current.Session == null)
                {
                return;
                }
            HttpContext.Current.Session[key] = value;
                }
        private object GetFromSession(string key)
        {
            if (HttpContext.Current == null || HttpContext.Current.Session == null)
                {
            return null;
                }
            return HttpContext.Current.Session[key];
        }
        private void UpdateInSession(string key, object value)
        {
         HttpContext.Current.Session[key] = value;
        }
    }
}
